﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace EmptyASP.View
{
    public partial class Menu : System.Web.UI.UserControl
    {
        System.Security.Principal.IPrincipal User;
        protected void Page_Load(object sender, EventArgs e)
        {
            //User = ((Empty)sender).User;
            //return;
        }
        public void setActiveMenuItem(String category)
        {
            foreach (Control it in menuPanel.Controls)
            {
                if(it.GetType().BaseType==typeof(MenuItem))
                {
                    if (((MenuItem)it).category == category)
                    {
                        ((MenuItem)it).setSelected();                        
                    }
                }
            }
        }

        internal void addAdminButton()
        {
            MenuItem adminItem = (MenuItem)Page.LoadControl("~/View/MenuItem.ascx");
            adminItem.label="Administrator";
            adminItem.category="admin";
            adminItem.link="~/Admin/admin.aspx";
            menuPanel.Controls.Add(adminItem);
        }
    }
}